        function closeWizard(event)
        {
             window.close();
        }

        function getMailInfo(event)
        {
          document.getElementById("textsender").setAttribute("value",mysender);
          document.getElementById("textsubject").setAttribute("value",mysubject);
          document.getElementById("labelmailURI").setAttribute("value",mymsguri);   
        }

	var pfPath = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsILocalFile).path;
 
        var mysender=window.opener.TagMail.sender;
        var mysubject=window.opener.TagMail.subject;
       
        //The Identity of mail
        var mymsguri=window.opener.TagMail.mailURI;
       
        //Clear the tip string when focus on the textbox
        function clearText(){
            var tagtext=document.getElementById("texttagdesc");
            tagtext.setAttribute("value","")
        }

        function checkName(){
            document.getElementById("Nepomuk-tb-tag").canAdvance = (document.getElementById("texttagname").value!="");
        }

        function tagSummary(){          
            var tagname = document.getElementById("texttagname").value;
            var tagdesc;
            tagdesc = document.getElementById("texttagdesc").value;
            if(tagdesc == "Write your description here.")
            {
                tagdesc = "";
            }
            document.getElementById("labTagName").setAttribute("value","Name: "+tagname);
            document.getElementById("labTagDesc").setAttribute("value","Description: "+tagdesc);
        }

        function wizardFinish(){
            alert('Well Done');
        }
	    //Call the Python script from extension to save the tag

      function saveTag(){
                // create an nsILocalFile for the executable
        var file = Components.classes["@mozilla.org/file/local;1"]
                     .createInstance(Components.interfaces.nsILocalFile);
        file.initWithPath("/usr/bin/python");

        // create an nsIProcess
        var process = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
        process.init(file);
	


        var mail2tag = mymsguri;
	var tag2save = document.getElementById("texttagname").value;
	var desc2save = document.getElementById("texttagdesc").value;
        if(desc2save == "Write your description here.")
        {
	  desc2save = "";
        }

        // Run the process.
        // If first param is true, calling thread will be blocked until
        // called process terminates.
        // Second and third params are used to pass command-line arguments
        // to the process.

        var scriptPath = pfPath+"/extensions/thunderbird@nepomuk.org/chrome/content/scripts/python_calls.py";
	filePath=pfPath+"/extensions/thunderbird@nepomuk.org/chrome/content";
        var args = [scriptPath, filePath, "addTag", mail2tag, tag2save, desc2save];

	process.run(false, args, args.length);
      }

	function removeCurrent(event){
	  var tree = document.getElementById("tagTree");
	  var tbo = tree.treeBoxObject;

	  // get the row, col and child element at the point
	  var row = { }, col = { }, child = { };
	  tbo.getCellAt(event.clientX, event.clientY, row, col, child);

	  var cellText = tree.view.getCellText(row.value, col.value);

	  var currentelement = tree.treeBoxObject.view.getItemAtIndex(tree.currentIndex);
	  currentelement.parentNode.removeChild(currentelement);

                // create an nsILocalFile for the executable
        var file = Components.classes["@mozilla.org/file/local;1"]
                     .createInstance(Components.interfaces.nsILocalFile);
        file.initWithPath("/usr/bin/python");

        // create an nsIProcess
        var process = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
        process.init(file);
	


        var page2tag = mymsguri;
	var tag2del = cellText;

        // Run the process.
        // If first param is true, calling thread will be blocked until
        // called process terminates.
        // Second and third params are used to pass command-line arguments
        // to the process.

        var scriptPath = pfPath+"/extensions/thunderbird@nepomuk.org/chrome/content/scripts/python_calls.py";
	filePath=pfPath+"/extensions/thunderbird@nepomuk.org/chrome/content";
        var args = [scriptPath, filePath, "removeTag", page2tag, tag2del];
	process.run(true, args, args.length);

	  alert("The tag '"+cellText+"' has been deleted!");
	}

      function getTags(){
        // create an nsILocalFile for the executable
        var file = Components.classes["@mozilla.org/file/local;1"]
                     .createInstance(Components.interfaces.nsILocalFile);
        file.initWithPath("/usr/bin/python");

        // create an nsIProcess
        var process = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
        process.init(file);

        // Run the process.
        // If first param is true, calling thread will be blocked until
        // called process terminates.
        // Second and third params are used to pass command-line arguments
        // to the process.

        var scriptPath = pfPath+"/extensions/thunderbird@nepomuk.org/chrome/content/scripts/python_calls.py";
	var argUri = mymsguri;
	filePath=pfPath+"/extensions/thunderbird@nepomuk.org/chrome/content";
        var args = [scriptPath, filePath, "getTagsOf", argUri];
	process.run(true, args, args.length);
      }
      function showTags(){
	document.getElementById("Nepomuk-tb-tag").canAdvance="true";
	var mytree = document.getElementById("tagTree");
	mytree.builder.refresh();
      }